﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Galoap
{
    /// <summary>
    /// The PartOfSpeechQuestion class
    /// </summary>
    partial class PartOfSpeechQuestion : PhraseQuestion
    {
        /*
         * 
         * @ THIS IS A OLD PROTOTYPE OF THE GAME
         * 
        public Ontology[] Knowledge
        {
            get
            {
                pi.phrase = Document.First().ToString();
                try
                {
                    Answer.Load();
                    Answer a = this.GetMostFrequentAnswer<StringAnswer>().First();
                    if (a.Counter > 25)
                    {
                        string[] str = System.Text.RegularExpressions.Regex.Split(a.ToString(), "\n");
                        Ontology[] l = new Ontology[str.Length];
                        for (int i = 0; i < str.Length;i++) 
                        {
                            l[i]=Ontology.FromString(str[i]);
                        }
                        return l; 
                    }
                }
                catch (System.InvalidOperationException)
                {
                    // Document.Load();
                    return pi.PartOfSpeechRequest();
                }
                // Document.Load();
                return pi.PartOfSpeechRequest();
            }
        }

        /// <summary>
        /// The constructor of the PartOfSpeechQuestion
        /// </summary>
        public PartOfSpeechQuestion()
            : base()
        {
            Text = new QuestionText("Assegna la corretta categoria alle parole.");
        }
        
        /// <summary>
        /// Provides an ArrayList rapresenting the data of the PartOfSpeechQuestion
        /// </summary>
        /// <returns>the ArrayList for this PartOfSpeechQuestion</returns>
        public override string ToJSON()
        {
            StringBuilder sb = new StringBuilder("\"knowledge\":[");
            foreach (Ontology on in Knowledge)
            {
                sb.Append(on.ToJSON() + ",");
            }
            if (Knowledge.Length > 0) sb.Remove(sb.Length - 1, 1);
            sb.Append("]");

            return "{" + base.ToJSON() + ExtendJSON(sb.ToString()) + "}";
            
        }

        public override void Initialize()
        {
            base.Initialize();
        }
        */
    }  
}
